home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2005 March / Macworld CD March 2005 - Marathon Trilogy.iso / Shareware World / iPod / iPodderX.sit / iPodderX / iPodderX.app / Contents / Resources / crons.pl < prev    next >
Encoding:
Perl Script  |  2005-01-07  |  1.0 KB  |  48 lines

  1. #! /usr/bin/perl
  2.  
  3. #touch /tmp/podder_this_cron.txt
  4.  
  5. # iPodderX Cron Script
  6. # Contributed by Dave Slusher
  7. #
  8. # Based on original and rather faulty script
  9. # by August Trometer
  10.  
  11. $parameter = shift;
  12. $command = shift;
  13. $minute = -1;
  14.  
  15. if ($minute == -1) {
  16.     $minute = int(rand(60));
  17. }
  18.  
  19. $cron = "";
  20.  
  21. if ($parameter == 1 ) {
  22.     $cron = "$minute    *    *    *    *    $command >> /dev/null 2>&1";
  23. }
  24. if ($parameter == 2 ) {
  25.     $cron = "$minute    */3    *    *    *    $command >> /dev/null 2>&1";
  26. }
  27. if ($parameter == 3 ) {
  28.     $cron = "$minute    */6    *    *    *    $command >> /dev/null 2>&1";
  29. }
  30. if ($parameter == 4 ) {
  31.     $cron = "$minute    */12    *    *    *    $command >> /dev/null 2>&1";
  32. }
  33. if ($parameter == 5 ) {
  34.     $cron = "$minute    1    *    *    *    $command >> /dev/null 2>&1";
  35. }
  36. if ($parameter == 6 ) {
  37.     $cron = "$minute    1    */2    *    *    $command >> /dev/null 2>&1";
  38. }
  39.  
  40. system("crontab -l | grep -v \'iPodderX\' | cat > /tmp/podder_this_cron.txt");
  41.  
  42. open (OUTPUT, ">>/tmp/podder_this_cron.txt") || die "Cannot add cron line to temp file";
  43. print OUTPUT "$cron\n";
  44. close OUTPUT;
  45.  
  46. system("crontab /tmp/podder_this_cron.txt");
  47.  
  48. exit;